package cn.edu.xhu.web.action;

import java.util.List;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;

import cn.edu.xhu.base.BaseAction;
import cn.edu.xhu.domain.Test;

@Controller
@Scope("prototype")
public class TestAction extends BaseAction<Test>{
	
	/**
	 * 列表
	 * @return
	 */
	public String list() {
		List<Test> testList = testService.findAll();
		ActionContext.getContext().put("testList", testList);
		return "list";
	}
	
	/**
	 * 添加页面
	 * @return
	 */
	public String addUI() {
		return "addUI";
	}
	
	/**
	 * 添加
	 * @return
	 */
	public String add() {
		testService.save(model);
		return "show";
	}
	
	/**
	 * 删除
	 * @return
	 */
	public String delete() {
		testService.delete(model.getId());
		return "show";
	}
	
	/**
	 * 修改页面
	 * @return
	 */
	public String editUI() {
		Test test = testService.getById(model.getId());
		ActionContext.getContext().getValueStack().push(test);
		return "editUI";
	}
	
	/**
	 * 修改
	 * @return
	 */
	public String edit() {
		testService.update(model);
		return "show";
	}
}
